import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:flutter_animate/flutter_animate.dart';
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
import 'package:get/get.dart';
import 'package:sgy_flutter/ble/ble_manager.dart';
import 'package:sgy_flutter/extensions/get.dart';
import 'package:sgy_flutter/gen/assets.gen.dart';
import 'package:sgy_flutter/model/device_info.dart';
import 'package:sgy_flutter/model/product_type.dart';
import 'package:sgy_flutter/page/detail/widget/signal_view.dart';
import 'package:sgy_flutter/widget/app_dialog.dart';

import '../logic.dart';
import '../widget/ble_state_view.dart';

class DlsDoubleTopView extends GetView<DetailLogic> {
  const DlsDoubleTopView({super.key});

  @override
  Widget build(BuildContext context) {
    return Container(
      decoration: BoxDecoration(
        border: Border(bottom: BorderSide.none),
        color: Get.theme.primaryColor,
      ),
      padding: EdgeInsets.only(top: 20, bottom: 10, left: 26, right: 26),
      child: Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          IntrinsicHeight(
            child: Row(
              children: [
                Text(
                  "DLS",
                  style: TextStyle(
                    fontSize: 38,
                    color: Colors.white,
                    fontWeight: FontWeight.bold,
                  ),
                ),
                Container(
                  color: Colors.white,
                  height: double.infinity,
                  width: 2,
                  margin: EdgeInsets.symmetric(horizontal: 10, vertical: 4),
                ),
                Column(
                  mainAxisSize: MainAxisSize.min,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text(
                      "POWER METER",
                      style: TextStyle(
                          fontSize: 14,
                          color: Colors.white,
                          fontWeight: FontWeight.bold),
                    ),
                    Text(
                      "硬件版本".tr,
                      style: TextStyle(
                          fontSize: 14,
                          color: Colors.white,
                          fontWeight: FontWeight.bold),
                    ).marginOnly(top: 4),
                    Text(
                      "L:${controller.bleManager.deviceModel?.hardware ?? ''}-R:${controller.rightBleManager?.deviceModel?.hardware ?? ''}",
                      style: TextStyle(
                          fontSize: 14,
                          color: Colors.white,
                          fontWeight: FontWeight.bold),
                    ).marginOnly(top: 4),
                  ],
                ),
              ],
            ),
          ),
          Row(
            crossAxisAlignment: CrossAxisAlignment.end,
            children: [
              SignalView(
                bleManager: controller.bleManager,
                showDeviceId: true,
              ),
              SignalView(
                bleManager: controller.rightBleManager,
                showDeviceId: true,
              ).marginOnly(left: 6),
              Spacer(),
              BleStateView2(
                  rightBleManager: controller.rightBleManager,
                  bleManager: controller.bleManager,
                  builder: (left, right) {
                    return Container(
                      padding: EdgeInsets.symmetric(vertical: 4, horizontal: 8),
                      decoration: BoxDecoration(
                          color: Colors.white,
                          borderRadius: BorderRadius.circular(20)),
                      child: Text(
                        left && right ? "双边模式".tr : "单边模式".tr,
                        style: TextStyle(
                            fontSize: 12, color: Get.theme.primaryColor),
                      ),
                    );
                  }),
            ],
          ).marginOnly(top: 20)
        ],
      ),
    );
  }
}
